import uuid from 'uuid/v1'

/**
 * 生成uuid
 *
 * @returns {*}
 */
export function getUuid() {
  return uuid()
}

/**
 * 将文本中的url替换成超链接格式
 * @param text
 * @returns {*}
 */
export function replaceURLWithHTMLLinks(text) {
  var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i;
  return text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
}

export function isEmpty(text) {
  if (text === null || text.length === 0) {
    return true
  } else {
    return false
  }
}
